package com.my.chart;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.Log;

import com.my.trace.TrackPoints;

/**
 * Created by vic on 11/3/13.
 */
public class LineChart{
    final String TAG = "LineChart";
    //
    Paint linePaint;
    //
    public LineChart(int color){
        linePaint = new Paint();
        linePaint.setColor(color);
    }
/*
    public void drawLine(ArrayList<TrackPoint> trackLog, int idx, int size){
        Log.d(TAG, "drawLine");

        Canvas canvas = surfaceHolder.lockCanvas();

        //trackLog.(idx).altitude
        canvas.drawColor(Color.WHITE);

        surfaceHolder.unlockCanvasAndPost(canvas);

    }
*/
    public void drawLine(Canvas canvas, TrackPoints points, int idx, int size){
        if(idx >= points.getSize())  return;
        Log.d(TAG, "drawLine" + points.getSize());

        for(int i=idx; i<(idx+size-1); i++){
            if(i >= points.getSize())  break;

            canvas.drawLine((float) points.getVal(TrackPoints.VAL_ALTITUDE, i), i,
                    (float) points.getVal(TrackPoints.VAL_ALTITUDE, i + 1), i + 1,
                    linePaint);
        }

        //holder.unlockCanvasAndPost(canvas);
    }
}